12 typedef pair
<double, node
> edge
;
13 typedef map
<node
, vector
<edge
> > graph
;
18 while (cin
>> length
){
22 for (int i
=0; i
<cities
; ++i
){
25 g
[s
] = vector
<edge
>();
29 for (int i
=0; i
<edges
; ++i
){
33 g
[u
].push_back(edge(w
, v
));
34 g
[v
].push_back(edge(w
, u
));
38 priority_queue
<edge
, vector
<edge
>, greater
<edge
> > q
;
39 q
.push(edge(0.0, g
.begin()->first
));
42 node u
= q
.top().second
;
43 double w
= q
.top().first
;
46 if (visited
.count(u
)) continue;
50 vector
<edge
> &vecinos
= g
[u
];
51 for (int i
=0; i
<vecinos
.size(); ++i
){
52 node v
= vecinos
[i
].second
;
53 double w_extra
= vecinos
[i
].first
;
54 if (visited
.count(v
) == 0){
55 q
.push(edge(w_extra
, v
));
61 cout
<< "Not enough cable" << endl
;
63 printf("Need %.1lf miles of cable\n", total
);